package com.xiedafeng.www.view;

import com.xiedafeng.www.controller.MenuController;
import com.xiedafeng.www.po.User;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class MenuView {
    MenuController menuController=new MenuController();
    public void menu(User user){
        Button search=new Button("查询个人信息");
        Button modify=new Button("修改个人信息");
        Button circle=new Button("瓜圈广场");
        Button myEvent=new Button("我的瓜");
        Button collect=new Button("我的收藏");
        Button thumbsup=new Button("我的点赞");
        Button remark=new Button("我的评论");
        Button notice=new Button("我的通知");
        Button manage=new Button("管理员");

        GridPane gridPane=new GridPane();
        gridPane.add(search,0,0);
        gridPane.add(modify,0,1);
        gridPane.add(circle,0,2);
        gridPane.add(myEvent,0,3);
        gridPane.add(collect,0,4);
        gridPane.add(thumbsup,0,5);
        gridPane.add(remark,0,6);
        gridPane.add(notice,0,7);
        gridPane.add(manage,0,8);
        gridPane.setAlignment(Pos.CENTER);

        Scene scene=new Scene(gridPane);
        Stage stage=new Stage();
        stage.setScene(scene);

        modify.setOnMouseClicked(event -> {
            try {
                modifyInformation(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        search.setOnMouseClicked(event -> searchInformation(user));
        circle.setOnMouseClicked(event -> {
            try {
                enterCircle(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        myEvent.setOnMouseClicked(event -> {
            try {
                showUserEvent(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        thumbsup.setOnMouseClicked(event -> {
            try {
                showUserThumbUp(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        collect.setOnMouseClicked(event -> {
            try {
                showUserCollect(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        remark.setOnMouseClicked(event -> {
            try {
                showUserRemark(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        notice.setOnMouseClicked(event -> {
            try {
                showNotice(user);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });

        stage.showAndWait();
    }
    private void searchInformation(User user){
        menuController.searchInformation(user);
    }
    private void modifyInformation(User user) throws Exception {
        menuController.modifyInformation(user);
    }
    private void enterCircle(User user) throws Exception {
        menuController.enterCircle(user);
    }
    private void showUserEvent(User user) throws Exception {
        menuController.showUserEvent(user);
    }
    private void showUserThumbUp(User user) throws Exception {
        menuController.showUserThumbUp(user);
    }
    private void showUserCollect(User user) throws Exception {
        menuController.showUserCollect(user);
    }
    private void showUserRemark(User user) throws Exception{
        menuController.showUserRemark(user);
    }
    private void showNotice(User user) throws Exception {
        menuController.showNotice(user);
    }
}
